home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / 3DMF parser / 0.9 version / MFLABELS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-24  |  5.2 KB  |  228 lines  |  [TEXT/MPS ]

  1. /*==============================================================================
  2.  *
  3.  *    File:        MFLABELS.C
  4.  *
  5.  *    Function:    Enum/Flags lookup routines
  6.  *
  7.  *    Author(s):    Rick Wong (RWW)
  8.  *
  9.  *    Copyright:    (c) 1995 by Apple Computer, Inc., all rights reserved.
  10.  *
  11.  *    Change History (most recent first):
  12.  *        Fabio    Changed file name to 8 characters
  13.  *        F3K_RWW    GeneralPolygonHint.
  14.  *        F3A_RWW    MeshEdges and OrientationStyle.
  15.  *        F2K_RWW    File created.
  16.  *==============================================================================
  17.  */
  18.  
  19. #include "MFLABELS.H"
  20.  
  21. #include "MFERRORS.H"
  22. #include "MFTYPES.H"
  23. #include "MFTEXTUT.H"
  24.  
  25. /*==============================================================================
  26.  *    Enum Tables
  27.  *==============================================================================
  28.  */
  29. MF3D_EnumTable gMF3D_BooleanEnum[] =
  30. {    0x00000000,        "False",
  31.     0x00000001,        "True",
  32.     kMF3D_EndTable
  33. };
  34.  
  35. MF3D_EnumTable gMF3D_ShapeHintEnum[] =
  36. {    0x00000000,        "Convex",
  37.     0x00000001,        "Concave",
  38.     0x00000002,        "Complex",
  39.     kMF3D_EndTable
  40. };
  41.  
  42. MF3D_EnumTable gMF3D_FallOffEnum[] =
  43. {    0x00000000,        "None",
  44.     0x00000001,        "Linear",
  45.     0x00000002,        "Exponential",
  46.     0x00000003,        "Cosine",
  47.     kMF3D_EndTable
  48. };
  49.  
  50. MF3D_EnumTable gMF3D_PixelTypeEnum[] =
  51. {    0x00000000,        "RGB8",
  52.     0x00000001,        "RGB16",
  53.     0x00000002,        "RGB24",
  54.     0x00000003,        "RGB32",
  55.     kMF3D_EndTable
  56. };
  57.  
  58. MF3D_EnumTable gMF3D_EndianEnum[] =
  59. {    0x00000000,        "BigEndian",
  60.     0x00000001,        "LittleEndian",
  61.     kMF3D_EndTable
  62. };
  63.  
  64. MF3D_EnumTable gMF3D_BackfacingEnum[] =
  65. {    0x00000000,        "Both",
  66.     0x00000001,        "Culled",
  67.     0x00000002,        "Flipped",
  68.     kMF3D_EndTable
  69. };
  70.  
  71. MF3D_EnumTable gMF3D_FillStyleEnum[] =
  72. {    0x00000000,        "Filled",
  73.     0x00000001,        "Edges",
  74.     0x00000002,        "Points",
  75.     0x00000003,        "Empty",
  76.     kMF3D_EndTable
  77. };
  78.  
  79. MF3D_EnumTable gMF3D_InterpolationStyleEnum[] =
  80. {    0x00000000,        "None",
  81.     0x00000001,        "Vertex",
  82.     0x00000002,        "Pixel",
  83.     kMF3D_EndTable
  84. };
  85.  
  86. MF3D_EnumTable gMF3D_OrientationStyleEnum[] =
  87. {    0x00000000,        "CounterClockwise",
  88.     0x00000001,        "Clockwise",
  89.     kMF3D_EndTable
  90. };
  91.  
  92. MF3D_EnumTable gMF3D_SubdivisionMethodEnum[] =
  93. {    0x00000000,        "Constant",
  94.     0x00000001,        "WorldSpace",
  95.     0x00000002,        "ScreenSpace",
  96.     kMF3D_EndTable
  97. };
  98.  
  99. MF3D_EnumTable gMF3D_AxisEnum[] =
  100. {    0x00000000,        "X",
  101.     0x00000001,        "Y",
  102.     0x00000002,        "Z",
  103.     kMF3D_EndTable
  104. };
  105.  
  106. MF3D_EnumTable gMF3D_ShaderUVBoundaryEnum[] =
  107. {    0x00000000,        "Wrap",
  108.     0x00000001,        "Clamp",
  109.     kMF3D_EndTable
  110. };
  111.  
  112. MF3D_EnumTable gMF3D_PackingEnum[] =
  113. {    0x00000000,        "Include",
  114.     0x00000001,        "Exclude",
  115.     kMF3D_EndTable
  116. };
  117.  
  118. MF3D_EnumTable gMF3D_GeneralPolygonHintEnum[] =
  119. {    0x00000000,        "Complex",
  120.     0x00000001,        "Concave",
  121.     0x00000002,        "Convex",
  122.     kMF3D_EndTable
  123. };
  124.  
  125. /*==============================================================================
  126.  *    Flag Tables
  127.  *==============================================================================
  128.  */
  129. MF3D_FlagTable gMF3D_MetafileFlags[] =
  130. {    0x00000000,        "Normal",
  131.     0x00000001,        "Stream",
  132.     0x00000002,        "Database",
  133.     kMF3D_EndTable
  134. };
  135.  
  136. MF3D_FlagTable gMF3D_DisplayGroupStateFlags[] =
  137. {    0x00000000,        "None",
  138.     0x00000001,        "Inline",
  139.     0x00000002,        "DoNotDraw",
  140.     0x00000004,        "NoBoundingBox",
  141.     0x00000008,        "NoBoundingSphere",
  142.     0x00000010,        "DoNotPick",
  143.     kMF3D_EndTable
  144. };
  145.  
  146. MF3D_FlagTable gMF3D_PickPartsFlags[] =
  147. {    0x00000000,        "Object",
  148.     0x00000001,        "Face",
  149.     0x00000002,        "Edge",
  150.     0x00000004,        "Vertex",
  151.     kMF3D_EndTable
  152. };
  153.  
  154. MF3D_FlagTable gMF3D_CapsFlags[] =
  155. {    0x00000000,        "None",
  156.     0x00000001,        "Bottom",
  157.     0x00000002,        "Top",
  158.     kMF3D_EndTable
  159. };
  160.  
  161. /*==============================================================================
  162.  *    MF3D_MatchLabelByValue
  163.  *
  164.  *    Try to match inValueToMatch in the given label table.
  165.  *    Return the matching string in outLabelText (unless outLabelText is NULL).
  166.  *        Remember to free the string later!
  167.  *==============================================================================
  168.  */
  169. MF3DErr
  170. MF3D_MatchLabelByValue(
  171.     MF3D_LabelTablePtr    inLabelTablePtr,
  172.     const MF3DUns32        inValueToMatch,
  173.     MF3DCStringPtr        *outLabelText)
  174. {
  175.     MF3DErr    result;
  176.  
  177.     /* Assume we will fail to match (rare pessimism) */
  178.     result = kMF3DErrIllegalEnum;
  179.  
  180.     while (inLabelTablePtr->str != NULL)
  181.     {    if (inValueToMatch == inLabelTablePtr->value)
  182.         {    result = kMF3DNoErr;    /* match! */
  183.             if (outLabelText != NULL)
  184.             {    MF3DCStringPtr    str;
  185.                 str = MF3D_DuplicateCString(inLabelTablePtr->str);
  186.                 if (str == NULL)
  187.                     result = kMF3DErrOutOfMemory;
  188.                 else
  189.                     *outLabelText = str;
  190.             }
  191.             break;                    /* ### SUCCESSFUL LOOP EXIT ### */
  192.         }
  193.         ++inLabelTablePtr;
  194.     }
  195.  
  196.     return result;
  197. }
  198.  
  199. /*==============================================================================
  200.  *    MF3D_MatchLabelByName
  201.  *
  202.  *    Try to match inLabelText in the given label table.
  203.  *==============================================================================
  204.  */
  205. MF3DErr
  206. MF3D_MatchLabelByName(
  207.     MF3D_LabelTablePtr    inLabelTablePtr,
  208.     MF3DCStringPtr        inLabelText,
  209.     MF3DUns32            *outLabelValue)
  210. {
  211.     MF3D_LabelTablePtr    labelPtr;
  212.     MF3DErr result;
  213.  
  214.     /* Assume we will fail to match (rare pessimism) */
  215.     result = kMF3DErrIllegalEnum;
  216.  
  217.     for (labelPtr = inLabelTablePtr; labelPtr->str != NULL; ++labelPtr)
  218.     {    if (MF3D_CmpStrInsensitive(inLabelText, labelPtr->str) == 0)
  219.         {    result = kMF3DNoErr;    /* match! */
  220.             if (outLabelValue != NULL)
  221.                 *outLabelValue = labelPtr->value;
  222.             break;                    /* ### SUCCESSFUL LOOP EXIT ### */
  223.         }
  224.     }
  225.  
  226.     return result;
  227. }
  228.